//
//  UserTypeViewController.m
//  Home
//
//  Created by 吴军虎吴军虎 on 16/4/26.
//  Copyright © 2016年 LanJue. All rights reserved.
//

#import "UserTypeViewController.h"
#import "UserButton.h"
#import "YHYDesigneViewsViewController.h"

@interface UserTypeViewController ()

@end

@implementation UserTypeViewController

- (void)viewWillAppear:(BOOL)animated {
    
    self.navigationController.navigationBarHidden = YES;
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigationBar"] forBarMetrics:UIBarMetricsDefault];
    if ([self.navigationController.navigationBar respondsToSelector:@selector( setBackgroundImage:forBarMetrics:)]){
        NSArray *list=self.navigationController.navigationBar.subviews;
        for (id obj in list) {
            if ([obj isKindOfClass:[UIImageView class]]) {
                UIImageView *imageView=(UIImageView *)obj;
                NSArray *list2=imageView.subviews;
                for (id obj2 in list2) {
                    if ([obj2 isKindOfClass:[UIImageView class]]) {
                        UIImageView *imageView2=(UIImageView *)obj2;
                        imageView2.hidden=YES;
                    }
                }
            }
        }
    }
    UserButton *button = (UserButton *)[self.view viewWithTag:2001];
    UserButton *button2 = (UserButton *)[self.view viewWithTag:2002];
    [button selfTouchUpInside];
    [button2 selfTouchUpInside];
}

- (void)viewWillDisappear:(BOOL)animated {
    self.navigationController.navigationBarHidden = NO;
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
}

- (void)viewDidLoad {
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
//    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStylePlain target:self action:@selector(Back:)];
//    self.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor];
    
    self.view.backgroundColor = GH;
    
    UserButton *userSBtn = [[UserButton alloc] init];
    [self.view addSubview:userSBtn];
    userSBtn.titleStr = @"我是设计师";
    userSBtn.tag = 2001;
    [userSBtn addTarget:self action:@selector(userButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [userSBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(140 * AUTO_WIDTH);
        make.centerX.mas_equalTo(@0);
    }];
    
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(@0);
        make.height.mas_equalTo(@1);
        make.left.right.mas_equalTo(@0);
    }];
    
    UserButton *userNBtn = [[UserButton alloc] init];
    [self.view addSubview:userNBtn];
    userNBtn.titleStr = @"寻找设计师";
    userNBtn.tag = 2002;
    [userNBtn addTarget:self action:@selector(userButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [userNBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.mas_equalTo(-140 * AUTO_WIDTH);
        make.centerX.mas_equalTo(@0);
    }];
    
}



#pragma mark -- 发布任务
- (void)userButtonAction:(UserButton *)btn {
    
    [btn selfTouchUpInside];
    if (btn.tag == 2001) {
        
        YHYDesigneViewsViewController *informationC = [[YHYDesigneViewsViewController alloc]init];
        [self.navigationController pushViewController:informationC animated:YES];
        informationC.mun = 1;
        [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"userType"];
    } else {
        
        YHYDesigneViewsViewController *informationC = [[YHYDesigneViewsViewController alloc]init];
        informationC.mun = 2;
        [self.navigationController pushViewController:informationC animated:YES];
        [[NSUserDefaults standardUserDefaults] setObject:@"2" forKey:@"userType"];
    }
    
    
}

@end
